package com.ss.android.common.ad;

import android.content.Context;

import com.bytedance.article.common.a.g;
import com.ss.android.article.browser.R;
import com.ss.android.common.app.AbsApplication;
import com.ss.android.common.lib.MobClickCombiner;

import org.json.JSONException;
import org.json.JSONObject;

public final class MobAdClickCombiner {
    private static EventModel a = null;

    public static void onAdEvent(Context context, String arg12, String arg13, long arg14, long arg16, JSONObject arg18, int arg19) {
        MobAdClickCombiner.onAdEvent(
                context,
                "umeng",
                arg12,
                arg13,
                arg14,
                arg16,
                arg18,
                arg19);
    }

    public static void onAdEvent(Context context,
                                 String arg13,
                                 String arg14,
                                 String arg15,
                                 long arg16,
                                 long arg18,
                                 JSONObject arg20,
                                 int arg21) {
        int v2_3 = 0;
        int v3_1;
        String v4_1 = null;
        if (context == null) {
            return;
        }

        try {
            if (MobAdClickCombiner.isTestChannel()) {
                EventModel v3 = new EventModel(arg14, arg15, arg16, arg18, arg20);
                if (MobAdClickCombiner.a != null && (MobAdClickCombiner.a.equals(v3))) {
                    String v2_1 = "";
                    if (arg20 != null) {
                        v2_1 = (String) arg20.get("log_extra");
                    }

                    int v4 = R.string.debug_waring_duplicated_event;
                    android.support.design.a.a(context, context.getString(v4, new Object[]{arg14, arg15, String.valueOf(arg16), String.valueOf(arg18), v2_1}), null, 3000);
                }

                if (!v3.isValid()) {
//                    goto label_43;
                } else {
                    MobAdClickCombiner.a = v3;
                }
            }

            label_43:
            switch (arg21) {
                case 0: {
                    v4_1 = "ad_event_unknown";
                    break;
                }
                case 1: {
                    v4_1 = "ad_event_detail";
                    break;
                }
                case 2:
                    v4_1 = "ad_event_feed";
                    break;
                case 3:
                    v4_1 = "ad_event_splash";
                    break;
                case 4:
                    v4_1 = "ad_event_web";
                    break;
                case 5:
                    v4_1 = "ad_event_landing";
                    break;
                default:
                    v4_1 = "ad_event_unknown";
                    break;
            }

            v3_1 = 0;
            if (arg16 <= 1000000000) {
                v3_1 = 4;
                if ((MobAdClickCombiner.isTestChannel()) && arg21 != 4) {
                    if (arg16 <= 0) {
                        android.support.design.a.a(context, context.getString(com.ss.android.article.browser.R.string.debug_waring_no_adid, new Object[]{arg14, arg15}), null, 3000);
                    } else {
                        android.support.design.a.a(context, context.getString(com.ss.android.article.browser.R.string.debug_waring_adid_error, new Object[]{arg14, arg15, String.valueOf(arg16)}), null, 3000);
                    }
                }
            }

            if (arg20 == null || !arg20.has("log_extra") || (android.support.design.a.isTextEmpty(arg20.getString("log_extra")))) {
                v3_1 |= 1;
                if ((MobAdClickCombiner.isTestChannel()) && arg21 != 4) {
                    android.support.design.a.a(context, context.getString(com.ss.android.article.browser.R.string.debug_waring_no_log_extra, new Object[]{arg14, arg15, String.valueOf(arg16)}), null, 3000);
                }
            }

            if (!android.support.design.a.isTextEmpty(arg15)) {
                v2_3 = 0;
                if (arg15.contains("show")) {
                    v2_3 = 1;
                } else if (arg15.contains("click")) {
                    v2_3 = 2;
                }

                v2_3 = v2_3 * 10 + v3_1;
            } else {
                v2_3 = v3_1;
            }
        } catch (Throwable v2) {
            v2.printStackTrace();
        }
        try {
//            label_107:
            g.serviceMonitor(v4_1, v2_3, null);
        } catch (Throwable v2) {
//            label_145:
            v2.printStackTrace();
        }

        MobClickCombiner.onEvent(context, arg13, arg14, arg15, arg16, arg18, arg20);
    }

    public static void onAdEvent(Context arg13, String arg14, String arg15, long arg16, String arg18) {
        JSONObject v10 = new JSONObject();
        try {
            v10.put("log_extra", arg18);
        } catch (JSONException v2) {
            v2.printStackTrace();
        }

        MobAdClickCombiner.onAdEvent(arg13, arg14, arg15, arg16, 0, v10, 2);
    }

    public static void onAdEvent(Context arg13, String arg14, String arg15, long arg16, long arg18, String arg20, int arg21) {
        JSONObject v10 = new JSONObject();
        try {
            v10.put("log_extra", arg20);
        } catch (JSONException v2) {
            v2.printStackTrace();
        }

        MobAdClickCombiner.onAdEvent(arg13, "umeng", arg14, arg15, arg16, arg18, v10, arg21);
    }

    private static boolean isTestChannel() {
        try {
            String v0_1 = AbsApplication.getApplication().getChannel();
            if (!"local_test".equals(v0_1) && !"local_dev".equals(v0_1)) {
                boolean v0_2 = false;
                return v0_2;
            }

            return true;
        } catch (Exception v0) {
        }
        boolean v0_2 = false;
        return v0_2;
    }
}

